﻿var _PageIndex;
var _PageUpCount;
var _Direction;
function LoadingDataList(tagObjectId)
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/membership/favoriteslist.aspx"),
        data: {
            otype:          "loadingfavoriteslist",
            page:           _PageIndex,
            upcount:        _PageUpCount
        },
        beforeSend: function() {
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html($("#loading1").html());
        },
        success: function(data, textStatus) {  
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html(data);
        }
    });
}
function pagination(page, upcount, direction)
{
    _PageIndex=page;
    _PageUpCount=upcount;
    _Direction=direction;
    LoadingDataList("divFavoriteslist");
}
function MoveToShoppingCart(_obj)
{
     $.ajax({
            type    :   "POST",
            url     :   prependOrgName("/membership/favoriteslist.aspx"),
            data    :   { otype: "movefavoritesitem", _itemid : _obj.itemid },
            async   :   false,
            success :   function(data, textStatus){
                if(data == "succeeded"){
                     LoadingDataList("divFavoriteslist");
                }
                else {
                    alert(data);
                }
            }
        });
}
function RemoveFromFavorites(_obj)
{
    $.ajax({
        type    :   "POST",
        url     :   prependOrgName("/membership/favoriteslist.aspx"),
        data    :   { otype: "removefavoritesitem", _itemid : _obj.itemid },
        async   :   false,
        success :   function(data, textStatus){
            if(data == "succeeded"){
                LoadingDataList("divFavoriteslist");
            }
            else {
                alert(data);
            }
        }
    });
}